<style lang="scss">
  @import "../../../utils/base.scss";
</style>
<template>
  <div>
    <!-- 基本信息 -->
    <template id="businessInfo">
      <!-- <div class="qheader" :style="{borderBottom: '0px solid rgb(210,210,210)'}">
        <div>
          <span >业务信息</span>
          <Button v-if="!ifedit"  size="small"  style="margin-left: 115px;" @click="template = true">导入模板</button>
        </div>
      </div> -->

      <Modal v-model="template" width="80" title="选择模板" @on-ok="template_ok()">
        <Table ref="startegies" border stripe :columns="severColumns2" :data="startegies">
          <template slot-scope="{ row, index }" slot="direction">
            <span>{{row.oriPool + '（到）'+ row.tarPool}}</span>
          </template>
          <template slot-scope="{ row, index }" slot="action">
            <Button type="primary" size="small" @click="show_detail_strategy(row)">详情</Button>
          </template>
        </Table>

        <div style="margin: 10px;overflow: hidden">
          <div style="float: right;">
            <Page :current="page" :total="total_num" show-total show-elevator show-sizer @on-change="changePage"
              @on-page-size-change="changePageSize"></Page>
          </div>
        </div>
      </Modal>

      <div v-if="show_detail">
        <Modal @on-ok="show_detail_click" @on-cancel="show_detail_click" v-model="show_detail" :loading="loading"
          :mask-closable="false" :closable="false" title="模板详情" width="80%">
          <Form ref="add_startegies" :model="add_startegies" label-position="left" :label-width="120">
            <Row>
              <Col span="8">
              <FormItem label="模板名称:" prop="title">
                <p>{{add_startegies.title}}</p>
              </FormItem>
              </Col>
            </Row>
            <Row>
              <Col span="8">
              <FormItem label="源资源池:" prop="oriPool">
                <p>{{add_startegies.oriPool}}</p>
              </FormItem>
              </Col>
              <Col span="8" class="col_left">
              <FormItem label="目的资源池:" prop="tarPool">
                <p>{{add_startegies.tarPool}}</p>
              </FormItem>
              </Col>
            </Row>
            <Row>
              <Col span="8">
              <FormItem label="策略类型:" prop="netType">
                <p>{{add_startegies.netType}}</p>
              </FormItem>
              </Col>
            </Row>
            <Row>
              <Col span="8">
              <FormItem label="源接入系统:" prop="oriSys">
                <p>{{add_startegies.oriSys}}</p>
              </FormItem>
              </Col>
              <Col span="8" class="col_left">
              <FormItem label="目的接入系统:" prop="tarSys">
                <p>{{add_startegies.tarSys}}</p>
              </FormItem>
              </Col>
            </Row>

            <Row style="padding-top: 10px;overflow-x:auto" id="startegies">
              <Table size="small" :columns="severColumns" :data="add_startegies.startegies" border>
                <template slot-scope="{ row, index }" slot="index">
                  <p>{{index+1}}</p>
                </template>
                <template slot-scope="{ row, index }" slot="direction">
                  <p>{{add_startegies.startegies[index].direction}}</p>
                </template>
                <template slot-scope="{ row, index }" slot="oriAddr">
                  <Input type="textarea" :autosize="{minRows: 1,maxRows: 999}"
                    v-model="add_startegies.startegies[index].oriAddr" :readonly="true" />
                  <!-- <p>{{add_startegies.startegies[index].oriAddr}}</p> -->
                </template>
                <template slot-scope="{ row, index }" slot="oriMapAddr">
                  <Input type="textarea" :autosize="{minRows: 1,maxRows: 999}"
                    v-model="add_startegies.startegies[index].oriMapAddr" :readonly="true" />
                  <!-- <p>{{add_startegies.startegies[index].oriMapAddr}}</p> -->
                </template>
                <template slot-scope="{ row, index }" slot="oriPortFrom">
                  <p>{{add_startegies.startegies[index].oriPortFrom}}</p>
                </template>
                <!-- <template slot-scope="{ row, index }" slot="oriPortTo" >
									<p>{{add_startegies.startegies[index].oriPortTo}}</p>
								</template> -->
                <template slot-scope="{ row, index }" slot="targetAddr">
                  <Input type="textarea" :autosize="{minRows: 1,maxRows: 999}"
                    v-model="add_startegies.startegies[index].targetAddr" :readonly="true" />
                  <!-- <p>{{add_startegies.startegies[index].targetAddr}}</p> -->
                </template>
                <template slot-scope="{ row, index }" slot="targetMapAddr">
                  <Input type="textarea" :autosize="{minRows: 1,maxRows: 999}"
                    v-model="add_startegies.startegies[index].targetMapAddr" :readonly="true" />
                  <!-- <p>{{add_startegies.startegies[index].targetMapAddr}}</p> -->
                </template>
                <template slot-scope="{ row, index }" slot="targetPortfrom">
                  <p>{{add_startegies.startegies[index].targetPortfrom}}</p>
                </template>
                <!-- <template slot-scope="{ row, index }" slot="targetPortTo" >
									<p>{{add_startegies.startegies[index].targetPortTo}}</p>
								</template> -->
                <template slot-scope="{ row, index }" slot="tcpProtocol">
                  <p>{{add_startegies.startegies[index].tcpProtocol}}</p>
                </template>
                <!-- <template slot-scope="{ row, index }" slot="udpProtocol" >
									<p>{{add_startegies.startegies[index].udpProtocol}}</p>
								</template> -->
                <template slot-scope="{ row, index }" slot="appProtocol">
                  <p>{{add_startegies.startegies[index].appProtocol}}</p>
                </template>
                <template slot-scope="{ row, index }" slot="purpose">
                  <p>{{add_startegies.startegies[index].purpose}}</p>
                </template>
              </Table>
            </Row>
          </Form>
        </Modal>
      </div>

      <div class="gcontent">
        <Form ref="businessInfo" :rules="networkInfoValidate" :model="networkInfo" :label-width="labelWidth"
          label-position="left" class="form form_left">
          <!-- <Row v-if="!ifedit">
						<Col span="8">
						<FormItem label="策略模板:" prop="title">
							<Button size="small" class="data_button" @click="template = true" >选择模板</button>
						</FormItem>
						</Col>
					</Row> -->
          <Row>
            <Col span="8">
            <FormItem label="源资源池:" prop="oriPool">
              <Input v-if="ifedit" v-model="networkInfo.oriPool" :readonly="readonly" />
              <Select v-else v-model="networkInfo.oriPool" :transfer='true' style="z-index:999">
                <Option value="哈尔滨资源池">哈尔滨资源池</Option>
                <Option value="呼和浩特资源池">呼和浩特资源池</Option>
                <Option value="业支非池化">业支非池化</Option>
                <Option value="信息港资源池">信息港资源池</Option>
                <Option value="省公司">省公司</Option>
                <Option value="专业公司">专业公司</Option>
                <Option value="其他">其他</Option>
              </Select>
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem label="目的资源池:" prop="tarPool">
              <Input v-if="ifedit" v-model="networkInfo.tarPool" :readonly="true" />
              <Select v-else v-model="networkInfo.tarPool" :transfer='true' style="z-index:999">
                <Option value="哈尔滨资源池">哈尔滨资源池</Option>
                <Option value="呼和浩特资源池">呼和浩特资源池</Option>
                <Option value="业支非池化">业支非池化</Option>
                <Option value="信息港资源池">信息港资源池</Option>
                <Option value="省公司">省公司</Option>
                <Option value="专业公司">专业公司</Option>
                <Option value="其他">其他</Option>
              </Select>
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem label="策略类型:" prop="netType">
              <Input v-if="ifedit" v-model="networkInfo.netType" :readonly="readonly" />
              <Select v-else v-model="networkInfo.netType" :transfer='true' style="z-index:999">
                <Option value="公网">公网</Option>
                <Option value="承载网">承载网</Option>
                <Option value="内网">内网</Option>
                <Option value="专线">专线</Option>
                <Option value="CMNetDCI_vpn">CMNetDCI_vpn</Option>
              </Select>
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <component v-if="networkInfo.netType==='公网'" ref="file1" :is="'file'" :ifedit="ifedit"
              :filesList="filesList" v-model="networkInfo.netOpenAppendix"></component>
            </Col>
          </Row>
          <p style="color:#bbb;margin-bottom: 20px">公网申请请上传近一月dmz主机安全扫描截图，若any网络申请请提交安全管理中心合规平台备案截图。</p>
          <Row>
            <Col span="8">
            <FormItem label="源接入系统:" prop="oriSysId">
              <Input v-if="ifedit" v-model="networkInfo.oriSys" :readonly="readonly" />
              <Select v-else v-model="networkInfo.oriSysId" :transfer='true' @on-change="setOriSysInfo" filterable>
                <Option v-for="(item,index) in allSysList2" :value="item.id" :key="index">{{item.sysName}}</Option>
                <Option :value="0">外部系统</Option>
              </Select>
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem v-show="networkInfo.oriSysId!=0" label="源接入系统联系人:">
              <Input v-model="networkInfo.oriSysContact" :readonly="readonly" />
            </FormItem>
            <FormItem v-show="networkInfo.oriSysId==0 && !ifedit" prop="oriSys" label="外部系统名称:">
              <Input v-model="networkInfo.oriSys" :readonly="ifedit" />
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem v-if="networkInfo.oriSysId!=0" label="源接入系统联系人电话:" prop="oriSysPhone">
              <Input v-model="networkInfo.oriSysPhone" :readonly="readonly" />
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem v-if="networkInfo.oriSysId!=0" label="源接入系统联系人邮箱:" prop='oriSysMail'>
              <Input v-model="networkInfo.oriSysMail" :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>

          <Row>
            <Col span="8">
            <FormItem label="目的接入系统:" prop="tarSysId">
              <Input v-if="ifedit" v-model="networkInfo.tarSys" :readonly="readonly" />
              <Select v-else v-model="networkInfo.tarSysId" :transfer='true' filterable @on-change="setTarSysInfo">
                <Option v-for="(item,index) in allSysList2" :value="item.id" :key="index">{{item.sysName}}</Option>
                <Option :value="0">外部系统</Option>
              </Select>
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem v-if="networkInfo.tarSysId!=0" label="目的接入系统联系人:">
              <Input v-model="networkInfo.tarSysContact" :readonly="readonly" />
            </FormItem>
            <FormItem v-show="networkInfo.tarSysId==0 && !ifedit" prop="tarSys" label="外部系统名称:">
              <Input v-model="networkInfo.tarSys" :readonly="ifedit" />
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem v-if="networkInfo.tarSysId!=0" label="目的接入系统联系人电话:" prop="tarSysPhone">
              <Input v-model="networkInfo.tarSysPhone" :readonly="readonly" />
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem v-if="networkInfo.tarSysId!=0" label="目的接入系统联系人邮箱:" prop="tarSysMail">
              <Input v-model="networkInfo.tarSysMail" :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>

          <Row>
            <Col span="8">
            <FormItem :label="networkInfo.usetime!=null?'策略使用时长：':'策略开始时间'" prop="usetime">
              <Input v-if="(ifedit && networkInfo.usetime!=null)" v-model="networkInfo.usetime" :readonly="readonly" />
              <Input v-if="(ifedit && networkInfo.usetime==null)" v-model="networkInfo.actTime" :readonly="readonly" />
              <Select v-if="!ifedit" v-model="networkInfo.usetime" :transfer='true' style="z-index:999">
                <Option value="长期">长期</Option>
                <Option value="短期">短期</Option>
              </Select>
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem v-if="networkInfo.usetime === '短期' || (networkInfo.actTime!='' && networkInfo.usetime==null)"
              label="策略失效日期：" prop="deadline">
              <DatePicker :options="disabledDate" v-model="networkInfo.deadline" style="width: 100%;" type="date"
                :disabled="ifedit" placeholder="请选择日期"></DatePicker>
            </FormItem>
            </Col>
          </Row>

          <Row>
            <Col span="22" style="width:96.666667%">
            <FormItem label="申请描述:" prop="reqDes">
              <Input v-model="networkInfo.reqDes" :readonly="ifedit" maxlength="255" show-word-limit
                placeholder="请描述申请原因及用途" type="textarea" :autosize="{minRows: 4,maxRows: 6}" />
            </FormItem>
            </Col>
          </Row>
        </Form>
      </div>

    </template>

  </div>
</template>
<script>
  import ajax from "../../../ajax_util"
  import Axios from 'axios'
  import {
    mavonEditor
  } from 'mavon-editor'
  import 'mavon-editor/dist/css/index.css'
  import inputSearch from '../../../base/input_search'
  import file from './file'

  export default {
    name: "apply",
    components: {
      mavonEditor,
      inputSearch,
      file
    },
    data() {
      const validateEntryEndTime = (rule, value, callback) => {
        // if (value === '') {
        // 	callback(new Error('请选择期策略失效时间'));
        // } else {
        // 	if (this.networkInfo.actTime === '') {
        // 		callback(new Error('请选择策略生效时间'));
        // 	} else if (this.networkInfo.actTime.getTime() > value.getTime()) {
        // 		callback(new Error('策略失效时间不能小于策略生效时间'));
        // 	} else {
        // 		callback()
        // 	}
        // }

        if (this.networkInfo.usetime === '短期') {
          if (value === '') {
            callback(new Error('请选择期策略失效时间'));
          }else{
              callback()
          }
        } else {
          if (this.networkInfo.usetime === '') {
            callback(new Error('请选择策略生效时间'));
          }else{
              callback()
          }
        }


      };
      
      const validateoriSysName = (rule, value, callback) => {
        console.log("networkInfo.oriSysId = ",this.networkInfo.oriSysId, this.networkInfo.oriSys)
        if(this.networkInfo.oriSysId == 0 && this.networkInfo.oriSys == ''){
          callback(new Error('请选择策略生效时间'));
        }else{
          callback()
        }
      }
      return {
        add_startegies: {
          id: "",
          title: '',
          show: false,
          isupdate: false,
          title: "",
          netType: "",
          oriPool: "",
          tarPool: '',
          oriSys: "",
          tarSys: "",
          startegies: [],
        },
        show_detail: false,
        startegies: [],
        selection_temp: '',
        template: false,
        countSys: [],
        total_num: 0,

        loading: true,
        data: [],

        page: 1,
        pageSize: 10,
        search_param: '',
        url_id: '0',
        strategyyUrl: this.CONFIG.progress_url + "/net-strategy",

        reqId: "",
        mdvalue: "",
        dataInfoEdit: 0,
        showFileMould: false,
        httpHeader: {
          Authorization: this.$store.state.token
        },
        disabledDate: {
          disabledDate(date) {
            return date && date.valueOf() < Date.now() - 24 * 60 * 60 * 1000 || date.valueOf() > 4070880000000;
          }
        },
        networkInfoValidate: {
          usetime: [{
            required: true,
            type: 'string',
            message: '请选择策略使用时长',
            trigger: 'change'
          }, ],
          deadline: [{
            required: true,
            validator: validateEntryEndTime,
            trigger: 'blur'
          }],
          oriPool: [{
            required: true,
            type: 'string',
            message: '请输入源资源池',
            trigger: 'change'
          }, ],
          tarPool: [{
            required: true,
            type: 'string',
            message: '请输入目的资源池',
            trigger: 'change'
          }, ],
          netType: [{
            required: true,
            type: 'string',
            message: '请选择策略类型',
            trigger: 'change'
          }, ],
          oriSysId: [{
            required: true,
            type: 'number',
            message: '请选择源接入系统',
            trigger: 'change'
          }, ],
          oriSys:  [{
            required: true,
            type: 'string',
            message: '请填写外部系统名称',
            trigger: 'change'
          }, ],
          oriSysContact: [{
            required: true,
            type: 'string',
            message: '请输入源接入系统联系人',
            trigger: 'change'
          }, ],

          tarSysId: [{
            required: true,
            type: 'number',
            message: '请选择目的接入系统',
            trigger: 'change'
          }, ],
          tarSys: [{
            required: true,
            type: 'string',
            message: '请填写外部系统名称',
            trigger: 'change'
          }, ],

          reqDes: [{
            required: true,
            type: 'string',
            message: '请输入申请描述',
            trigger: 'blur'
          }, ],
        },
        severColumns: [
          //  {
          //     title: "序号",
          //     align: "center",
          //     width: 60,
          //     slot: "index",
          //     fixed: 'left'
          // },
          {
            title: "访问方向 (*必填)",
            align: "center",
            minWidth: 200,
            key: "direction",
            slot: "direction",
          },
          {
            title: "源地址 (*必填)",
            align: "center",
            width: 240,
            key: "oriAddr",
            slot: "oriAddr"
          },
          {
            title: "源地址对应的映射IP (选填)",
            align: "center",
            width: 240,
            key: "oriMapAddr",
            slot: "oriMapAddr"
          },
          {
            title: "源端口",
            align: "center",
            width: 120,
            key: "oriPortFrom",
            slot: "oriPortFrom",
            // children: [
            //     {
            //         title: '从',
            //         align: 'center',
            //         width: 110,
            //         key: "oriPortFrom",
            //         slot: "oriPortFrom"
            //     },
            //     {
            //         title: '到',
            //         align: 'center',
            //         width: 110,
            //         key: "oriPortTo",
            //         slot: "oriPortTo"
            //     },
            // ]
          },
          {
            title: "目的地址 (*必填)",
            align: "center",
            width: 240,
            key: "targetAddr",
            slot: "targetAddr"
          },
          {
            title: "目的地址对应的映射IP (选填)",
            align: "center",
            width: 240,
            key: "targetMapAddr",
            slot: "targetMapAddr"
          },
          {
            title: "目的端口 (*必填)",
            align: "center",
            width: 130,
            key: "targetPortfrom",
            slot: "targetPortfrom",
            // children: [
            //     {
            //         title: '从',
            //         align: 'center',
            //         width: 130,
            //         key: "targetPortfrom",
            //         slot: "targetPortfrom",
            //     },
            //     {
            //         title: '到',
            //         align: 'center',
            //         width: 130,
            //         key: "targetPortTo",
            //         slot: "targetPortTo"
            //     },
            // ]
          },
          {
            title: "传输协议 (*必填)",
            align: "center",
            width: 130,
            key: "tcpProtocol",
            slot: "tcpProtocol",
            // children: [
            //     {
            //         title: "TCP",
            //         align: "center",
            //         width: 100,
            //         key: "tcpProtocol",
            //         slot: "tcpProtocol"
            //     },
            //     {
            //         title: 'UDP',
            //         align: 'center',
            //         width: 100,
            //         key: "udpProtocol",
            //         slot: "udpProtocol"
            //     },
            // ]
          },

          {
            title: "应用层协议 (选填)",
            align: "center",
            width: 130,
            key: "appProtocol",
            slot: "appProtocol"
          },
          {
            title: "策略用途 (*必填)",
            align: "center",
            width: 200,
            key: "purpose",
            slot: "purpose"
          },

        ],
        oriuserList: this.PoriuserList,
        taruserList: this.PtaruserList,
        fileUrl: this.CONFIG.file_url,
        readonly: true, //是否只读
        labelWidth: 140,
        bealoonTrue: true,
        file: null,
        loadingStatus: false,
        fileUpLoadAction: "",
        name: "",
        istrue: true,
        networkInfo: this.Papply,
        currentChoose: '',
        allSysList2: [],
      }
    },

    created: function() {},
    mounted: function() {
      this.get_all_strategy();
      this.getAllSys();
    },
    computed: {
      severColumns2() {
        let severColumns2 = []
        severColumns2.push({
          title: '选择',
          key: 'id',
          width: 70,
          align: 'center',
          render: (h, params) => {
            let id = params.row.id;
            let flag = false;
            if (this.currentChoose === id) {
              flag = true
            } else {
              flag = false
            }
            let self = this
            return h('div', [
              h('Radio', {
                props: {
                  value: flag
                },
                on: {
                  'on-change': () => {
                    console.log(' params.row', params.row)
                    this.selection_temp = params.row
                    self.currentChoose = id;
                  }
                }
              })
            ])
          }
        });
        severColumns2.push({
          title: "策略模板名称",
          align: "center",
          width: 200,
          key: "title",
        });
        severColumns2.push({
          title: "访问方向 (*必填)",
          align: "center",
          minWidth: 300,
          key: "direction",
          slot: "direction",
        });
        severColumns2.push({
          title: "源接入系统",
          align: "center",
          width: 200,
          key: "oriSys",
        });
        severColumns2.push({
          title: "目的接入系统",
          align: "center",
          width: 200,
          key: "tarSys",
        });
        severColumns2.push({
          title: "查看",
          align: "center",
          width: 80,
          slot: "action",
          fixed: 'right',
        })
        return severColumns2;
      },
    },

    methods: {
      getAllSys() {
        var url = this.CONFIG.progress_url + "/system-map/for/net"
        var that = this;
        ajax.get({
          url: url,
          that: that,
          params: null,
          success: function(data) {
            that.allSysList2 = data
          }
        })
      },
      show_detail_strategy(row) {
        console.log('row', row)
        this.template = false;
        this.add_startegies = row;
        this.show_detail = true;
      },
      show_detail_click() {
        this.show_detail = false;
        this.template = true;
      },
      // 设置目的系统人信息
      setTarSysInfo(value, name = "外部系统") {
        console.log(value)
        if (value == "0") {
          this.networkInfo.tarSys = name
          this.networkInfo.tarSysId = 0
          this.networkInfo.tarSysContactId = 0
          this.networkInfo.tarSysContact = "无"
          this.networkInfo.tarSysPhone = "无"
          this.networkInfo.tarSysMail = "无"
        } else {
          this.allSysList2.some(item => {
            if (value == item.id) {
              console.log(item)
              this.networkInfo.tarSys = item.sysName
              this.getUserInfo(item.amId, "tarSys")
              return true
            }
          })
        }

      },
      setOriSysInfo(value, name = "外部系统") {
        console.log(value)
        if (value == "0") {
          this.networkInfo.oriSys = name
          this.networkInfo.oriSysId = 0
          this.networkInfo.oriSysContactId = 0
          this.networkInfo.oriSysContact = "无"
          this.networkInfo.oriSysPhone = "无"
          this.networkInfo.oriSysMail = "无"
        } else {
          this.allSysList2.some(item => {
            if (value == item.id) {
              console.log(item)
              this.networkInfo.oriSys = item.sysName
              this.getUserInfo(item.amId, "OriSys")
              return true
            }
          })
        }
      },
      //获取系统负责人信息
      getUserInfo(userId, sys) {
        var that = this;
        var url = this.CONFIG.url_know + '/user/' + userId;
        ajax.get({
          url: url,
          that: that,
          success: function(data) {
            console.log("user----->", data)
            if (sys == "OriSys") {
              that.networkInfo.oriSysContactId = data.id
              that.networkInfo.oriSysContact = data.user_name
              that.networkInfo.oriSysPhone = data.phone
              that.networkInfo.oriSysMail = data.email
            } else if (sys == "tarSys") {
              that.networkInfo.tarSysContactId = data.id
              that.networkInfo.tarSysContact = data.user_name
              that.networkInfo.tarSysPhone = data.phone
              that.networkInfo.tarSysMail = data.email
            }
          }
        })
      },

      checkori(list) {
        this.oriuserList = list
        list.forEach(item => {
          this.networkInfo.oriSysContactId = item.id
          this.networkInfo.oriSysContact = item.user_name
          this.networkInfo.oriSysPhone = item.phone
          this.networkInfo.oriSysMail = item.email
        })
      },
      checktar(list) {
        this.taruserList = list
        list.forEach(item => {
          this.networkInfo.tarSysContactId = item.id
          this.networkInfo.tarSysContact = item.user_name
          this.networkInfo.tarSysPhone = item.phone
          this.networkInfo.tarSysMail = item.email
        })
      },
      validate() {
        console.log('this.networkInfo.netOpenAppendix', this.networkInfo.netOpenAppendix == '')
        var isSubmit = false
        if (this.networkInfo.netType === "公网") {
          if (this.networkInfo.netOpenAppendix == null || this.networkInfo.netOpenAppendix == '') {
            this.$Message.error('请上传公网申请附件');
            return isSubmit
          }
        }
        this.$refs["businessInfo"].validate((valid) => {
        	if (valid) {
        		isSubmit = true
        	} else {
        		this.$refs.base.scrollTop = document.getElementById("businessInfo").offsetTop - 100
        		this.$Message.error('请填写必填项');
            isSubmit = false
        	}
        })
        return isSubmit
      },

      //格式化日期
      formatDate(value) {
        var date = new Date(value * 1000);
        var year = date.getFullYear();
        var month = this.padDate(date.getMonth() + 1);
        var day = this.padDate(date.getDate());
        return year + '-' + month + '-' + day;
      },
      padDate(value) {
        return value < 10 ? '0' + value : value;
      },
      handleCreateOriSys(val) {
        this.getAllSys();
        this.allSysList2.push({
          id: 0,
          sysName: val,
        })
        this.networkInfo.oriSys = val;
        this.networkInfo.oriSysId = 0;
        this.networkInfo.oriSysContactId = 0
        this.networkInfo.oriSysContact = "无"
        this.networkInfo.oriSysPhone = "无"
        this.networkInfo.oriSysMail = "无"
      },
      handleCreateTarSys(val) {
        this.getAllSys();
        this.allSysList2.push({
          id: 0,
          sysName: val,
        })
        this.networkInfo.tarSys = val;
        this.networkInfo.tarSysId = 0
        this.networkInfo.tarSysContactId = 0
        this.networkInfo.tarSysContact = "无"
        this.networkInfo.tarSysPhone = "无"
        this.networkInfo.tarSysMail = "无"
      },
      in_array(list, value) {
        for (var i = 0; i < list.length; i++) {
          if (list[i].sysName == value && list[i].id != 0) {
            return true;
          }
        }
        return false;
      },
      setTarSysInfo2(value) {
        console.log('setTarSysInfo2', value, this.in_array(this.allSysList2, value))
        // console.log(this.in_array(this.allSysList2, value))
        if (!this.in_array(this.allSysList2, value) && value) {
          // this.getAllSys();
          // this.allSysList2.push({
          //   id: 0,
          //   sysName: value
          // })
          this.networkInfo.tarSys = value
          this.networkInfo.tarSysId = 0
          this.networkInfo.tarSysContactId = 0
          this.networkInfo.tarSysContact = "无"
          this.networkInfo.tarSysPhone = "无"
          this.networkInfo.tarSysMail = "无"
        } else {
          this.allSysList2.some(item => {
            if (value == item.sysName) {
              console.log(item)
              this.networkInfo.tarSysId = item.id
              this.networkInfo.tarSys = item.sysName
              this.getUserInfo(item.amId, "tarSys")
              return true
            }
          })
        }
        console.log('this.allSysList2---->', this.allSysList2)
      },
      setOriSysInfo2(value) {
        console.log('setOriSysInfo2', value, this.in_array(this.allSysList2, value))
        // console.log(this.in_array(this.allSysList2, value))
        if (!this.in_array(this.allSysList2, value)) {
          // this.getAllSys();
          // this.allSysList2.push({
          //   id: 0,
          //   sysName: value
          // })
          this.networkInfo.oriSys = value
          this.networkInfo.oriSysId = 0
          this.networkInfo.oriSysContactId = 0
          this.networkInfo.oriSysContact = "无"
          this.networkInfo.oriSysPhone = "无"
          this.networkInfo.oriSysMail = "无"
          console.log('111111111111111111', value)
        } else {
          console.log('2222222222222222222', value)
          this.allSysList2.some(item => {
            if (value == item.sysName) {
              console.log(item)
              this.networkInfo.oriSysId = item.id
              this.networkInfo.oriSys = item.sysName
              this.getUserInfo(item.amId, "OriSys")
              return true
            }
          })
        }
        console.log('this.allSysList2---->', this.allSysList2)
      },
      template_ok() {
        console.log('this.selection_temp', this.selection_temp)
        var i = []
        if (this.selection_temp != '') {
          var temp = this.selection_temp
          temp['startegies'].forEach(item => {
            var insert = {}
            for (var key in item) {
              if (key != 'id' && key != 'netId') {
                insert[key] = item[key]
              }
            }
            i.push(insert)
          })
          this.networkInfo.startegies = i
          this.networkInfo.oriPool = temp['oriPool']
          this.networkInfo.tarPool = temp['tarPool']
          this.networkInfo.netType = temp['netType']
          this.setOriSysInfo2(temp['oriSys'])
          this.setTarSysInfo2(temp['tarSys'])
          this.$Message.success('导入模板成功！')
        }
      },
      changePage(page) {
        console.log('page', Object.prototype.toString.call(page) == '[object Number]')
        var that = this;
        if (page != undefined && page > 0 && page != null && Object.prototype.toString.call(page) ===
          '[object Number]') {
          that.page = page;
        } else {
          that.page = 1;
        }
        var param = {
          current: that.page,
          pageSize: that.pageSize,
          title: this.search_param,
        }
        console.log('param:', param)
        var url = this.strategyyUrl + '/names';
        ajax.get({
          url: url,
          that: that,
          params: param,
          success: function(data) {
            console.log('changePage_data', data)
            that.startegies = data['records'];
            that.total_num = data['total'];
          }
        })
      },

      changePageSize(pageSize) {
        this.pageSize = pageSize;
        this.url_id = sessionStorage.getItem("url_id")
        if (this.url_id === "0") {
          this.get_all_strategy();
        } else if (this.url_id === "1") {
          var param = sessionStorage.getItem("param");
          this.search(param);
        }
      },


      get_all_strategy() {
        var that = this;
        var url = that.strategyyUrl + "/names";
        ajax.get({
          url: url,
          that: that,
          success: function(data) {
            console.log('get_all_strategy:', data)
            that.countSys = data
            sessionStorage.setItem("url_id", "0");
            that.changePage();
          }
        })
      },

      search(param) {
        if (param === '') {} else {
          this.changePage(1)
        }
      },
    },
    props: {
      filesList: {},
      allSysList: {},
      ifedit: {},
      Papply: {},
      PoriuserList: {
        type: Array,
        default: []
      },
      PtaruserList: {
        type: Array,
        default: []
      },
    },
    watch: {
      Papply(newV, old) {
        console.log("newV--------->", newV)
        this.networkInfo = newV
      },
      PoriuserList(newV, old) {
        console.log("PoriuserList--------->", newV)
        this.oriuserList = newV
      },
      PtaruserList(newV, old) {
        console.log("PtaruserList--------->", newV)
        this.taruserList = newV
      }
    }
  }
</script>
